var year = new Date().getFullYear();
var mouth = new Date().getDate();

document.querySelector("#year").innerHTML = year;
document.querySelector("#mouth").innerHTML = mouth;

function runnian(y){
    return !!(y % 400 === 0 || (y % 4 === 0 && y % 100 !== 0));
}

var days = 0;
for(var i = 1980;i<year;i++){
    if (runnian(i)){
        days +=366;
    }else {
        days +=365;
    }
}
console.log(days);

for(var a = 0;a<mouth;a++){
    switch (a){
        case 1:
            days +=31;
            break;
        case 2:
            if (runnian(year)){
                days +=29;
            }else {
                days +=28;
            }
            break;
        case 3:
            days +=31;
            break;
        case 4:
            days +=30;
            break;
        case 5:
            days +=31;
            break;
        case 6:
            days +=30;
            break;
        case 7:
            days +=31;
            break;
        case 8:
            days +=31;
            break;
        case 9:
            days +=30;
            break;
        case 10:
            days +=31;
            break;
        case 11:
            days +=30;
            break;
        case 12:
            days +=31;
            break;
    }
}
console.log(days);

var day = 0;
switch (mouth){
    case 1:
        day +=31;
        break;
    case 2:
        if (runnian(year)){
            day +=29;
        }else {
            day +=28;
        }
        break;
    case 3:
        day +=31;
        break;
    case 4:
        day +=30;
        break;
    case 5:
        day +=31;
        break;
    case 6:
        day +=30;
        break;
    case 7:
        day +=31;
        break;
    case 8:
        day +=31;
        break;
    case 9:
        day +=30;
        break;
    case 10:
        day +=31;
        break;
    case 11:
        day +=30;
        break;
    case 12:
        day +=31;
        break;
}

var prevday = 0;
if (mouth == 1){
    prevday +=31;
}else{
    switch (mouth-1){
        case 1:
            prevday +=31;
            break;
        case 2:
            if (runnian(year)){
                prevday +=29;
            }else {
                prevday +=28;
            }
            break;
        case 3:
            prevday +=31;
            break;
        case 4:
            prevday +=30;
            break;
        case 5:
            prevday +=31;
            break;
        case 6:
            prevday +=30;
            break;
        case 7:
            prevday +=31;
            break;
        case 8:
            prevday +=31;
            break;
        case 9:
            prevday +=30;
            break;
        case 10:
            prevday +=31;
            break;
        case 11:
            prevday +=30;
            break;
        case 12:
            prevday +=31;
            break;
    }
}
console.log(prevday);

days +=2;
var num = 42;
var start = days % 7;
if(start == 0){
    start += 7;
}
var thisday = new Date().getDate();
var nextday = num - day - start;
var date1 = document.querySelector("#date1");
    for(var n = prevday - start +1; n <= prevday; n++){
        date1.innerHTML+="<span class='change'>"+n+"</span>"
    }


for(var d = 1;d <= day; d++){
    if(d == thisday){
        date1.innerHTML+="<span class='today'>"+d+"</span>"
    }else {
        date1.innerHTML+="<span>"+d+"</span>"
    }
}
    for(var m = 1;m<=nextday;m++){
        date1.innerHTML+="<span class='change'>"+m+"</span>"
    }
